<!DOCTYPE html>
<!--suppress ALL-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous" />
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
<div class="container-fluid" id="app">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12 text-center" style="background-color: red; color: white" >
                <h3>蜗牛书店</h3>
            </div>
        </div>
    </div>

    <div class="container">

        <div class="row">
            <div class="col-md-4 col-md-offset-4" style="border: 1px solid #cccccc ;border-radius: 5px;margin-top: 10px">
                <p th:text="${errorInfo}" th:if="${!#strings.isEmpty(errorInfo)}"></p>
                <form th:action="@{/user/login}" method="post">
                    <div class="form-group">
                        <label for="exampleInputEmail1">username:</label>
                        <input type="text" name="username" class="form-control" id="exampleInputEmail1" placeholder="请输入用户名">
                    </div>
                    <div class="form-group">
                        <label for="exampleInputPassword1">password</label>
                        <input type="password" name="password" class="form-control" id="exampleInputPassword1" placeholder="请输入密码">
                    </div>

                    <div class="form-group">
                        <label for="code">验证码</label>
                        <input type="text" name="code" class="form-control" id="code" onblur="validateCode(this)" placeholder="请输入验证码">
                        <a href="javascript:void(0)" onclick="reflushCode()"><img th:src="@{/user/login/getKapatchaImage}" id="imgCode" />点击刷新</a>
                    </div>

                    <button type="submit" class="btn btn-default">登 录</button> <a th:href="@{/reg.html}">去注册</a>
                </form>
            </div>
        </div>

    </div>

    <script>
        function reflushCode(){
            let url = "/user/login/getKapatchaImage?d="+new Date().valueOf();
            let img = document.getElementById("imgCode");
            img.src = url;
        }

        //验证 验证码
        function validateCode(obj){
            //alert(obj.value);
            //发送ajax请求

        }
    </script>

    <div class="container">

    </div>
</div>

</body>
</html>